package com.hz.${p.packageName}.interfaces.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hz.base.beans.vo.CommonResult;
import com.hz.base.beans.vo.PageEntity;
import com.hz.base.beans.vo.QueryParams;
import com.hz.beans.code.HzOperateCode;
import com.hz.beans.${p.packageName}.entity.${p.entityName};
import com.hz.common.beans.constant.DemoResult;
import com.hz.interfaces.${p.packageName}.inf.I${p.entityName}Interface;
import com.hz.${p.packageName}.service.inf.I${p.entityName}Service;

/**
 * I${p.entityName}Service
 * @author ${p.author}
 * @since [0.0.1]
 * @version [0.0.1,${p.date}]
 */
@Service("${p.declareName}Interface")
public class ${p.entityName}Interface implements I${p.entityName}Interface{
	
	@Autowired
	private I${p.entityName}Service ${p.declareName}Service;
	

	@Override
	public CommonResult<${p.entityName}> query${p.entityName}(Long id) {
		CommonResult<${p.entityName}> cr = new DemoResult<>();
		cr = ${p.declareName}Service.selectByPrimaryKey(cr,id);
		cr.setOperate(HzOperateCode.QUERY_${p.upperName});
		return cr;
	}

	@Override
	public CommonResult<${p.entityName}> add${p.entityName}(${p.entityName} ${p.declareName}) {
		CommonResult<${p.entityName}> cr = new DemoResult<>();
		cr = ${p.declareName}Service.insert(cr, ${p.declareName});
		cr.setOperate(HzOperateCode.ADD_${p.upperName});
		return cr;
	}
	
	@Override
	public CommonResult<PageEntity> queryForPage(QueryParams<${p.entityName}> queryParams) {
		CommonResult<PageEntity> cr = new DemoResult<>();
		cr = ${p.declareName}Service.queryForPage(cr, queryParams);
		cr.setOperate(HzOperateCode.QUERY_${p.upperName}_PAGE);
		return cr;
	}

	@Override
	public CommonResult<List<${p.entityName}>> query${p.entityName}List(QueryParams<${p.entityName}> queryParams) {
		CommonResult<List<${p.entityName}>> cr = new DemoResult<>();
		cr = ${p.declareName}Service.queryForList(cr, queryParams);
		cr.setOperate(HzOperateCode.QUERY_${p.upperName}_LIST);
		return cr;
	}

	@Override
	public CommonResult<${p.entityName}> update${p.entityName}(${p.entityName} ${p.declareName}) {
		CommonResult<${p.entityName}> cr = new DemoResult<>();
		cr = ${p.declareName}Service.updateByPrimaryKey(cr, ${p.declareName});
		cr.setOperate(HzOperateCode.UPDATE_${p.upperName});
		return cr;
	}

	@Override
	public CommonResult<Object> delete${p.entityName}Array(Long[] ids) {
		CommonResult<Object> cr = new DemoResult<>();
		cr = ${p.declareName}Service.deleteObjectArray(cr, ids);
		cr.setOperate(HzOperateCode.DELETE_${p.upperName});
		return cr;
	}

	@Override
	public CommonResult<${p.entityName}> insertSelective(${p.entityName} ${p.declareName}) {
		CommonResult<${p.entityName}> cr = new DemoResult<>();
		cr = ${p.declareName}Service.insertSelective(cr, ${p.declareName});
		cr.setOperate(HzOperateCode.INSERTSELECTIVE_${p.upperName});
		return cr;
	}

	@Override
	public CommonResult<Object> deleteByList(List<${p.entityName}> ${p.declareName}List) {
		CommonResult<Object> cr = new DemoResult<>();
		cr = ${p.declareName}Service.deleteByList(cr, ${p.declareName}List);
		cr.setOperate(HzOperateCode.DELETELIST_${p.upperName});
		return cr;
	}

	@Override
	public CommonResult<List<${p.entityName}>> batchUpdate(List<${p.entityName}> ${p.declareName}List) {
		CommonResult<List<${p.entityName}>> cr = new DemoResult<>();
		cr = ${p.declareName}Service.batchUpdate(cr, ${p.declareName}List);
		cr.setOperate(HzOperateCode.BATCHUPDATE_${p.upperName});
		return cr;
	}

	@Override
	public CommonResult<List<${p.entityName}>> batchSave(List<${p.entityName}> ${p.declareName}List) {
		CommonResult<List<${p.entityName}>> cr = new DemoResult<>();
		cr = ${p.declareName}Service.batchSave(cr, ${p.declareName}List);
		cr.setOperate(HzOperateCode.BATCHSAVE_${p.upperName});
		return cr;
	}

}
